<?php

    include './phpQuery/phpQuery-onefile.php';
    echo '<pre>';

    $app_name = "极限摩托冬季版";

    header("Content-Type:text/html;charset=UTF-8");

    $url = 'http://zhushou.360.cn/detail/index/soft_id/';


    $search_url = 'http://zhushou.360.cn/search/index/?kw=';

    phpQuery::newDocumentFile($search_url . $app_name);

    $list = pq('.SeaCon ul li:eq(0) dl dt')->html();



    //正则取app_id
    $preg='/<a\s+href=\"\/detail\/index\/soft_id\/(.*)\?[^>]+\">/i';
    preg_match($preg, $list,$data);

    $app_id = $data[1];
    // echo $app_id;die;


    // $result = file_get_contents($url . $app_id);

    // $fp = fopen('d:/report/aaa.txt','a');
    // $fw = fwrite($fp, $result);
    // fclose($fp);die;

    phpQuery::newDocumentFile($url . $app_id);



    $title =  pq('title')->html();
    // echo $app_id;
    echo $title . '<br/>';

    $list = pq('.breif')->find('tbody')->find('tr')->html();
    if(empty($list)){
        echo 11;
        $list = pq('.html-brief')->find('tbody')->find('tr')->html();
    }
    echo $list;die;

    //软件内部版本号
    $preg = "/<!--versioncode:([^-]*).*>/i";

    preg_match($preg, $list,$aaa);
    var_dump($aaa);die;
    $str = str_replace('-->','',$aaa[1]);
    echo $str;


    $str =  str_replace(PHP_EOL,'',strip_tags($list));

    $data = explode('：', $str);
    echo '<pre>';
    $version = @array_shift(explode(' ', $data[3]));
    echo $version;

?>